package com.example.musicdemo.net

import com.google.gson.Gson
import java.lang.reflect.ParameterizedType

open class MRequest<RESPONSE>(val typeId:Int,val url: String, val handler: ResponseHandler<RESPONSE>) {
    /**
     * 解析网络请求
     */
    fun parseResult(result: String?): RESPONSE {
        val gson = Gson()
        //获取泛型类型
        val type = (this.javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0]
        return gson.fromJson(result, type);
    }


    fun excute() {
        println("这是啥子${this.url}")
        NetManger.manager.sendRequest(this)
    }

}